#include<iostream>
#include<stack>
using namespace std;
const int N = 110;
bool s[N];
int main()
{
	int t;string s1;cin >> s1;
	stack<int> st;
	for (int i = 0; i < s1.size(); i++)
	{
		if (s1[i] == '(' || s1[i] == '[') st.push(i);
		else
		{
			if (st.empty())continue;
			int t = st.top();
			if ((s1[t] == '(' && s1[i] == ')') || (s1[t] == '[' && s1[i] == ']'))
			{
				s[i] = true;
				s[t] = true;
				st.pop();
			}
		}
	}
	for (int i = 0; i < s1.size(); i++)
	{
		if (s[i] == true) cout << s1[i];
		else
		{
			if (s1[i] == '(' || s1[i] == ')')
			{
				cout << "()";
			}
			else if (s1[i] == '[' || s1[i] == ']')
			{
				cout << "[]";
			}
		}
	}
}
//#include<iostream>
//using namespace std;
//int main()
//{
//	string s1;
//	cin >> s1;
//	for (int i = 0; i < s1.size(); i++)
//	{
//		if (s1[i] == '(' && s1[i + 1] != ')')
//		{
//			cout << "()";
//		}
//		else if (s1[i] == '[' && s1[i + 1] != ']')
//		{
//			cout << "[]";
//		}
//		else if ((s1[i] == '(' && s1[i + 1] == ')') || (s1[i] == '[' && s1[i + 1] == ']'))
//		{
//			cout << s1[i] << s1[i + 1];
//			i++;
//		}
//		else if (s1[i] == ')') cout << "()";
//		else if (s1[i] == ']') cout << "[]";
//	}
//	return 0;
//}